Note...
At this point, i'm going work in the backend, so for see the fields and run the code, go to the Github Repositorie, for this especifíc folder look at the Session 25 APIs
A P I s
APIs are mechanisms that enable two software components to communicate with each other using a set of definitions and protocols. For example, the weather bureau's software system contains daily weather data. The weather app on your phone “talks” to this system via APIs and shows you daily weather updates on your phone.
Mozilla.org Docs about HTTP Status
PRINCIPAL ELEMENTS OF AN APY CONSUMER
- endpoint
- path
- parameters
- autentication
Some APIs
Happy C O D E
Consuming Key rest API
""
-Keny
Code implementation
function refresh(params) { let endpoint = "https://api.kanye.rest/"; fetch(endpoint) .then((response)=>response.json()) .then((json)=>{ document.querySelector("#api-response").innerHTML = `"${json.quote}"`; }); };
Consuming J O K E A P I
""
Code implementation
function jokeAPI() { let endpoint = "https://v2.jokeapi.dev/joke/" let category = "Programming?"; let paramteters = "blacklistFlags=sexist,explicit"; let urlToGET = endpoint + category + paramteters; fetch(urlToGET) .then((response)=>response.json()) .then((json)=>{ document.querySelector("#api-joke-response").innerHTML = `"${json.joke}"`; }); };